<!--
 * @Descripttion: 打印按钮
-->

<template>
	<div class="sc-button">
		<el-popconfirm :title="title" @confirm="batch_uncheck">
			<template #reference>
				<el-button type="info" plain v-auth="auth" :disabled="selectionList.length <= 0">反审核</el-button>
			</template>
		</el-popconfirm>
	</div>
</template>

<script>

export default {
	components: {},
	props: {
		selection: { type: Array, default: () => ([]) },
		apiObj: {
			type: Object, default: () => {
			}
		},
		auth: { type: String, default: '' },
		title: { type: String, default: '' },
		params: { type: Object, default: () => ({}) },
	},
	data() {
		return {
			selectionList: this.selection,
			paramsForm: this.params,
			number: 0
		}
	},
	// 监控data中的数据变化
	watch: {
		'selection'(val) {
			this.selectionList = val
		}
	},
	created() {

	},
	methods: {
		/**反审核*/
		async batch_uncheck() {
			if (!this.number) {
				this.number = 1;
				var ids = [];
				this.selectionList.forEach((item) => {
					ids.push(item.id)
				})
				if (ids.length != 0) {
					var reqData = { id: ids, ...this.paramsForm }
					var res = await this.apiObj.post(reqData);
					if (res.code == 1) {
						this.$emit('checkSuccess')
						this.$message.success("操作成功")
					} else {
						this.$alert(res.message, "提示", { type: 'error' })
					}
				}
			}
			this.number = 0;
		},
	}
}
</script>

<style scoped>
.sc-button {
	margin-left: 12px;
}
</style>
